﻿using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.Events;
using Selenium.Config;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Selenium.Driver
{
    [Obsolete]
    public class ChromeDriverManager
    {
        private const string _chromeDriverKey = "webdriver.chrome.driver";

        private static IWebDriver _webDriver;
        private static EventFiringWebDriver _eventFiringWebDriver;

        static ChromeDriverManager()
        {
            SeleniumConfig seleniumConfig = SeleniumConfig.Load();
            WebDriverConfig webDriverConfig = seleniumConfig.getWebDriver(
                SeleniumConfig.BrowserChrome);
            OptionConfig optionConfig = seleniumConfig.Option;

            _webDriver = new ChromeDriver(Path.GetDirectoryName(webDriverConfig.Path));
            _eventFiringWebDriver = new EventFiringWebDriver(_webDriver);
            _eventFiringWebDriver.Manage().Window.Maximize();
            _eventFiringWebDriver.Manage().Timeouts().ImplicitlyWait(
                new TimeSpan(0, 0, optionConfig.ImplicitlyWait));
            _eventFiringWebDriver.Manage().Timeouts().SetPageLoadTimeout(
                new TimeSpan(0, 0, optionConfig.PageLoadTimeout));
        }

        public static IWebDriver WebDriver
        {
            get { return _webDriver; }
        }
    }
}
